import { defHttp } from '@/utils/http/axios';
import {
  DictTreeItemModel,
  ScriptPageListGetResultModel,
  ScriptPageParams,
} from '@/api/resource/model/resourceAllModel';

const basePath = '/resource/resScriptManage/';
const buildUrl = (url: string) => basePath + url;
enum Api {
  ScriptPageList = 'pageQuery',
  ScriptAddOrUpdate = 'addOrUpdate',
  GetDictTree = 'getDictTree',
  ScriptDel = 'deleteById',
  TestConvertId = '/analysis/testConvertId',
}

export const getDictTree = () => defHttp.get<DictTreeItemModel>({ url: buildUrl(Api.GetDictTree) });

export const scriptPageList = (params: ScriptPageParams) =>
  defHttp.post<ScriptPageListGetResultModel>({
    url: buildUrl(Api.ScriptPageList),
    params: { page: params.page, pageSize: params.pageSize, t: params },
  });

export const scriptAddOrUpdate = (params: any) =>
  defHttp.post({ url: buildUrl(Api.ScriptAddOrUpdate), params });

export const testConvertId = (params: any) => defHttp.post({ url: Api.TestConvertId, params });

export const scriptDel = (id: string) => defHttp.get({ url: buildUrl(Api.ScriptDel) + '/' + id });
